<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台登陆</title>

<link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
<link href="/css/signin.css" rel="stylesheet">
<link rel="shortcut icon" href="/images/favicon.ico" />

</head>

<body>

<div class="signin">
	<div class="signin-head"><img src="/images/head_120.png" alt="" class="img-circle"></div>
	<form class="form-signin" role="form">
		<input type="text" class="form-control" placeholder="用户名" required autofocus id="inputName" name="name"/>
		<input type="password" class="form-control" placeholder="密码" required id="inputPasswd" name="passwd" />
		<div class="form-group clearfix form-group-lg">
            <input type="text" class="form-control pull-left" id="inputCode" name="captcha" placeholder="验证码" style="width: 200px" />
            <a href="#">
            	<img  class="control-label pull-right img-rounded" 
            		id='captchaimg' src="/admin_login/captcha" 
            		onclick="$(this).attr('src', '/admin_login/captcha?t='+Math.random())" style="width:90px;height:44px;"/>
            </a>
        </div>
        <div class="alert alert-warning hidden" role="alert" id="error-msg"></div>
		<button class="btn btn-lg btn-primary btn-block" type="button" id="btnSubmit">登录</button>
		<label class="checkbox" style="padding-left: 20px;">
			<input type="checkbox" value="remember" name="remember">记住密码
		</label>
	</form>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/plugins/jQuery/jquery-2.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
<script>
    $(function(){
        $('#inputName').focus();
        $('#btnSubmit').click(function(){
            $.post('/admin_login/login',$("form.form-signin").serialize(),function(obj){
                if(obj.status == 0){
                    $('#error-msg').html(obj.msg);
                    $('#error-msg').removeClass('hidden');
                    $('#captchaimg').attr('src', '/admin_login/captcha?t='+Math.random())
                }else{
                    location.href = '/admin_index/'; 
                }
            }); 
        });
        $('body').bind('keyup',function(event){
            if(event.keyCode == 13){
                $('#btnSubmit').click();
            }
        });
    })
</script>
</body>
</html>
